<template>
	<view>
		<z-paging ref="paging" v-model="dataList" @query="queryList">
			<view class="list">
				<view class="li" 
					
					v-for="(item,index) in dataList"
					:key="index">
					<view class="top">
						
						<view class="top-bg" :style="'background-image: url('+  item.image + ');'">
							
						</view>
						
						<view class="top-con">
							<view class="title">
								<text>{{item.title}}</text>
							</view>
							<view class="jl">
								<view class="price">
									<text>面值</text>
									<text>¥{{item.price}}</text>
								</view>
								<button @click="onJump('/pages/reserve/card/record?id='+item.id)">使用记录</button>
							</view>
							
							<view class="info">
								<view class="info-left">
									<text>次数：{{item.recordcount}}/{{item.num}}</text>
									<text>有效期：{{item.end_time}}</text>
								</view>
								
								<button @click="onJump('/pages/reserve/card/order?id='+item.id)" >预约使用</button>
							</view>
						</view>
						
					</view>
					<view class="mob">
						<view class="shows" v-if="item.sm_show">
							<view class="illustrate">
								<view class="title">使用说明：</view>
								<view class="info">
									<text>{{item.depict}}</text>
								</view>
							</view>
							
							<view class="img" @click="onSmShow(index)">
								<image :src="baseUrl+'/static/wximages/icon-13.png'" mode="widthFix"></image>
							</view>
						</view>
						<view class="desc" @click="onSmShow(index)">
							<text>使用说明：{{item.depict}}</text>
							<image :src="baseUrl+'/static/wximages/icon-13.png'" mode="widthFix"></image>
						</view>
						
					</view>
				</view>
			</view>
			
		</z-paging>
	</view>
</template>

<script>
	import { getCardList } from '@/api/reserve.js';
	export default {
		data() {
			return {
				dataList: [],
				baseUrl: this.$baseUrl
			}
		},
		methods: {
			onJump(url) {
				uni.navigateTo({
					url: url
				})
			},
			onSmShow(index) {
				this.dataList[index].sm_show = !this.dataList[index].sm_show
			},
			queryList(pageNo, pageSize) {
				// 此处请求仅为演示，请替换为自己项目中的请求
				const params = {
					page: pageNo,
					pageSize: pageSize
				}
				getCardList(params).then(res => {
					this.$refs.paging.complete(res.data.data);
				})
			}
		}
	}
</script>
<style>
	page {
		background: #003153;
	}
</style>
<style scoped lang="scss">
	.list {
		padding: 20rpx;
		.li {
			margin-top: 40rpx;
			.top {
				position: relative;
				height: 280rpx;
				border-radius: 20rpx 20rpx 0 0;
				padding: 30rpx;
				.top-bg {
					position: absolute;
					left: 0;
					top: 0;
					bottom: 0;
					right: 0;
					border-radius: 20rpx 20rpx 0 0;
					background-repeat: no-repeat;
					background-size: cover;
					opacity: .5;
				}
				.top-con {
					position: relative;
					
					left: 0;
					top: 0;
					bottom: 0;
					right: 0;
					z-index: 1;
				}
				.title {
					font-size: 35rpx;
					color: #FFFFFF;
				}
				.jl {
					display: flex;
					align-items: center;
					font-size: 30rpx;
					margin-top: 10rpx;
					color: #F96D28;
					.price {
						display: flex;
						align-items: center;
						text{
							&:nth-child(1) {
								font-size: 24rpx;
								margin-right: 13rpx;
							}
						}
					}
					button {
						width: 115rpx;
						height: 37rpx;
						border-radius: 100rpx 100rpx 100rpx 100rpx;
						border: 2rpx solid #FFFFFF;
						background: initial;
						font-size: 20rpx;
						color: #FFFFFF;
						line-height: 32rpx;
						text-align: center;
						margin-left: 20rpx;
						
					}
				}
				.info {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 38rpx;
					.info-left {
						display: flex;
						align-items: flex-start;
						flex-direction: column;
						font-size: 25rpx;
						color: #FFFFFF;
						text{
							margin-bottom: 5rpx;
						}
					}
					button {
						width: 140rpx;
						height: 49rpx;
						background: linear-gradient( 180deg, #F96D28 0%, rgba(249,109,40,0.7) 100%);
						border-radius: 100rpx 100rpx 100rpx 100rpx;
						font-size: 20rpx;
						color: #FFFFFF;
						text-align: center;
						line-height: 49rpx;
					}
				}
			}
			.mob {
				.shows {
					background: #FFFFFF;
					padding: 12rpx;
					.illustrate {
						.title {
							font-size: 20rpx;
							color: #666666;
							padding: 23rpx 0;
						}
						.info {
							display: flex;
							align-items: flex-start;
							flex-direction: column;
							font-size: 20rpx;
							color: #3D3D3D;
							line-height: 31rpx;
						}
					}
					.img {
						padding: 30rpx 0;
						display: flex;
						align-items: center;
						justify-content: center;
					}
					image {
						width: 25rpx;
						height: auto;
						transform: rotate(90deg);
					}
				}
				.desc {
					display: flex;
					align-items: center;
					justify-content: space-between;
					background: #FFFFFF;
					font-size: 20rpx;
					padding: 24rpx 10rpx;
					color: #666666;
					text {
						width: 200rpx;
						overflow: hidden;
					    text-overflow: ellipsis;
					    white-space: nowrap;
					}
					image {
						flex: 0 0 auto;
						width: 15rpx;
						height: auto;
					}
				}
				
			}
		}
	}
</style>